#ifndef __IpSocket_h__
#define __IpSocket_h__

#include <base/types.h>
#include <interfaces/SystemSocket.h>

#include <queue>

using namespace Greatewall::Interface;

namespace Greatewall
{
    namespace Network
    {
        class IpSocket : public SystemSocket
        {
        public:
            IpSocket(SocketEventMonitor& monitor, SysSockHandler hdl = -1);

            virtual ~IpSocket()
            {}

            virtual bool
            send(const char* buf, ssize_t& size, bool non_block = true);

            virtual bool
            recv(char*& buf, ssize_t& size, bool non_block = true);

        protected:

            bool _inited;

            struct OutboundNode
            {
                OutboundNode(const char* buf, ssize_t size)
                {
                    _offset = 0;
                    _size   = size;
                    _buf    = buf;
                }
                ~OutboundNode()
                {
                    delete _buf;
                }

                int         _offset;
                ssize_t     _size;
                const char* _buf;
            };
            std::queue<OutboundNode> _outbound_queue;

            uint64_t aligned_buf[1024*64];
        };
    }
}
#endif
